package com.itbaima.csmall.stock.webapi.quartz.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>RabbitMQConfig</p>
 *
 * @author Chen
 * @since 2023/3/8 15:54:54
 */
@Configuration
public class RabbitMQConfig {

    public static final String STOCK_EX = "stock_ex";
    public static final String STOCK_ROUTE = "stock_route";
    public static final String STOCK_QUEUE = "stock_queue";

    @Bean
    public DirectExchange stockDirectExchange() {
        return new DirectExchange(STOCK_EX);
    }

    @Bean
    public Queue stockQueue() {
        return new Queue(STOCK_QUEUE, false, false, false, null);
    }

    @Bean
    public Binding stockBinding() {
        return BindingBuilder.bind(stockQueue()).to(stockDirectExchange()).with(STOCK_ROUTE);
    }

}
